import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_common/ui/scaffold.dart';
import 'package:flutter_common/ui/widget/tab_menu.dart';

class TabMenuDemo extends StatefulWidget {
  const TabMenuDemo({Key? key}) : super(key: key);

  @override
  State<TabMenuDemo> createState() => _TabMenuDemoState();
}

class _TabMenuDemoState extends State<TabMenuDemo> {
  String desc = "";

  @override
  Widget build(BuildContext context) {
    return FxScaffold(
        appBar: FxAppBar(
          title: "菜单",
        ),
        body: _body());
  }

  Widget _body() {
    return TabMenu(
      titles: const ["测试1", "测试2", "测试3"],
      widgets: [
        Container(
          color: Colors.blue,
        ),
        Container(
          color: Colors.pink,
        ),
        Container(color: Colors.yellow)
      ],
      sliverHeight: 30,
      headWidget: InkWell(
        onTap: () {
          desc = "${desc}1";
          if (mounted) setState(() {});
        },
        child: desc.isEmpty
            ? Container(height: 10, color: Colors.blueAccent)
            : Container(
                height: 30,
                width: double.infinity,
                color: Colors.green,
                child: Text(desc),
              ),
      ),
    );
  }
}
